package com.yanshaohui.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@EnableSwagger2
public class Springboot2dbApplication {

	public static void main(String[] args) {
		SpringApplication.run(Springboot2dbApplication.class, args);
	}
	
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.yanshaohui.springboot.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Spring Boot使用多个datasource的测试")
                .description("参照我的码云地址：http://git.oschina.net/yanshaohui/")
                .termsOfServiceUrl("http://git.oschina.net/yanshaohui")
                .contact(new Contact("老码农的菜园","http://git.oschina.net/yanshaohui/","yanshaohui@live.com"))
                .version("0.1")
                .build();
    }
}
